package com.yzx.lifeassistants.activity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import me.xiaopan.swsv.CircularLayout;
import me.xiaopan.swsv.SpiderWebScoreView;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;
import cn.sharesdk.framework.Platform;
import cn.sharesdk.framework.Platform.ShareParams;
import cn.sharesdk.framework.PlatformActionListener;
import cn.sharesdk.framework.ShareSDK;
import cn.sharesdk.onekeyshare.OnekeyShare;
import cn.sharesdk.sina.weibo.SinaWeibo;
import cn.sharesdk.wechat.favorite.WechatFavorite;
import cn.sharesdk.wechat.friends.Wechat;
import cn.sharesdk.wechat.moments.WechatMoments;

import com.baidu.mapapi.search.core.PoiInfo;
import com.baidu.mapapi.search.core.SearchResult;
import com.baidu.mapapi.search.poi.OnGetPoiSearchResultListener;
import com.baidu.mapapi.search.poi.PoiDetailResult;
import com.baidu.mapapi.search.poi.PoiDetailSearchOption;
import com.baidu.mapapi.search.poi.PoiResult;
import com.baidu.mapapi.search.poi.PoiSearch;
import com.baidu.mapapi.search.share.OnGetShareUrlResultListener;
import com.baidu.mapapi.search.share.PoiDetailShareURLOption;
import com.baidu.mapapi.search.share.ShareUrlResult;
import com.baidu.mapapi.search.share.ShareUrlSearch;
import com.balysv.materialripple.MaterialRippleLayout;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.bean.SocializeEntity;
import com.umeng.socialize.controller.UMServiceFactory;
import com.umeng.socialize.controller.UMSocialService;
import com.umeng.socialize.controller.listener.SocializeListeners.SnsPostListener;
import com.umeng.socialize.media.UMImage;
import com.umeng.socialize.sso.QZoneSsoHandler;
import com.umeng.socialize.sso.UMQQSsoHandler;
import com.yzx.lifeassistants.R;
import com.yzx.lifeassistants.adapter.ShareListAdapter;
import com.yzx.lifeassistants.base.BaseActivity;
import com.yzx.lifeassistants.bean.SharePlatform;
import com.yzx.lifeassistants.common.CommonConstant;
import com.yzx.lifeassistants.utils.AppUtils;
import com.yzx.lifeassistants.utils.FileUtils;
import com.yzx.lifeassistants.utils.LogcatUtils;
import com.yzx.lifeassistants.utils.ScreenUtils;
import com.yzx.lifeassistants.utils.ToastUtils;
import com.yzx.lifeassistants.view.widget.CircularLoadingDialog;
import com.yzx.lifeassistants.view.widget.MyRatingBar;

/**
 * @Description: 美食详情界面
 * @author: yzx
 * @time: 2016-4-11 下午1:46:47
 */
@SuppressLint("InflateParams")
public class FoodInfoActivity extends BaseActivity implements OnClickListener,
		OnGetPoiSearchResultListener {

	private ImageButton backBtn;// 返回按钮
	private TextView nameTV;// 店名
	private TextView telTV;// 联系号码
	private TextView addressTV;// 地址
	private TextView tagTV;// 标签
	private TextView timeTV;// 营业时间
	private TextView priceTV;// 人均价格
	private MyRatingBar mRatingBar;// 综合评分
	private SpiderWebScoreView mScoreView;// 评分
	private CircularLayout mCircularLayout;//
	private TextView shareTV;// 分享
	private TextView callTelTV;// 咨询
	private TextView routeTV;// 路线规划

	private PoiInfo poiInfo;// 从上个界面传来的Poi信息
	private PoiSearch mPoiSearch;// POI搜索
	private ShareUrlSearch mShareUrlSearch;// 短串分享

	private PoiDetailResult result;// 搜索结果
	private CircularLoadingDialog dialog;// 加载框
	private List<String> ratingList;

	// //////////QQ,QZone使用友盟分享,其余使用ShareSDK分享//////////////
	private ShareParams shareParams;// 分享内容
	private PlatformActionListener listener;// 分享回调监听
	private String shareContent;// 分享文字
	private Bitmap bitmap;// 分享图片
	private String shareImagePath;// 分享图片路径
	private UMSocialService mShareController;// 友盟分享控制器
	private SnsPostListener snsPostListener;// 友盟分享回调监听
	private UMQQSsoHandler qqHandler;
	private QZoneSsoHandler qZoneHandler;

	private View shareView;// 分享弹框
	private AlertDialog theDialog;// 分享弹框

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_food_info);
		init();
		initView();
		setListener();
		initMaterialRipple();
		initShareDialog();
		initData();
	}

	/**
	 * 
	 * @Description: 初始化
	 */
	private void init() {
		Intent intent = getIntent();
		if (null == intent) {

		} else {
			poiInfo = intent.getParcelableExtra("poiInfo");
		}
	}

	/**
	 * 
	 * @Description: 初始化控件
	 */
	private void initView() {
		backBtn = (ImageButton) findViewById(R.id.food_info_back_btn);
		nameTV = (TextView) findViewById(R.id.food_info_name_tv);
		telTV = (TextView) findViewById(R.id.food_info_tel_tv);
		addressTV = (TextView) findViewById(R.id.food_info_address_tv);
		tagTV = (TextView) findViewById(R.id.food_info_tag_tv);
		timeTV = (TextView) findViewById(R.id.food_info_time_tv);
		priceTV = (TextView) findViewById(R.id.food_info_price_tv);
		mRatingBar = (MyRatingBar) findViewById(R.id.food_info_ratingbar);
		mScoreView = (SpiderWebScoreView) findViewById(R.id.food_info_spider_web);
		mCircularLayout = (CircularLayout) findViewById(R.id.food_info_circular_layout);
		shareTV = (TextView) findViewById(R.id.food_info_share_tv);
		callTelTV = (TextView) findViewById(R.id.food_info_call_tel_tv);
		routeTV = (TextView) findViewById(R.id.food_info_route_tv);
	}

	/**
	 * 
	 * @Description: 设置监听
	 */
	private void setListener() {
		backBtn.setOnClickListener(this);
		shareTV.setOnClickListener(this);
		callTelTV.setOnClickListener(this);
		routeTV.setOnClickListener(this);

	}

	/**
	 * 
	 * @Description: 瓷砖特效
	 */
	private void initMaterialRipple() {
		// 动态特效
		MaterialRippleLayout
				.on(shareTV)
				.rippleColor(
						Color.parseColor(CommonConstant.RIPPLE_COLOR_LITHT))
				.rippleAlpha(CommonConstant.RIPPLE_ALPHA).rippleHover(true)
				.create();
		MaterialRippleLayout
				.on(callTelTV)
				.rippleColor(
						Color.parseColor(CommonConstant.RIPPLE_COLOR_LITHT))
				.rippleAlpha(CommonConstant.RIPPLE_ALPHA).rippleHover(true)
				.create();
		MaterialRippleLayout
				.on(routeTV)
				.rippleColor(Color.parseColor(CommonConstant.RIPPLE_COLOR_DARK))
				.rippleAlpha(CommonConstant.RIPPLE_ALPHA).rippleHover(true)
				.create();

	}

	/**
	 * 
	 * @Description: 初始化分享框
	 */
	private void initShareDialog() {
		// 弹框
		theDialog = new AlertDialog.Builder(this, R.style.ShareDialog).create();
		theDialog.setCanceledOnTouchOutside(true);
		shareView = LayoutInflater.from(this).inflate(R.layout.dialog_share,
				null);
		List<SharePlatform> shareList = new ArrayList<SharePlatform>();
		shareList.add(new SharePlatform("QQ好友",
				R.drawable.ssdk_oks_skyblue_logo_qq_checked));
		shareList.add(new SharePlatform("QQ空间",
				R.drawable.ssdk_oks_skyblue_logo_qzone_checked));
		shareList.add(new SharePlatform("新浪微博",
				R.drawable.ssdk_oks_skyblue_logo_sinaweibo_checked));
		shareList.add(new SharePlatform("微信好友",
				R.drawable.ssdk_oks_skyblue_logo_wechat_checked));
		shareList.add(new SharePlatform("微信收藏",
				R.drawable.ssdk_oks_skyblue_logo_wechatfavorite_checked));
		shareList.add(new SharePlatform("微信朋友圈",
				R.drawable.ssdk_oks_skyblue_logo_wechatmoments_checked));
		shareList.add(new SharePlatform("更多", R.drawable.ic_share_more));
		ListView shareLV = (ListView) shareView
				.findViewById(R.id.dialog_share_lv);
		ShareListAdapter adapter = new ShareListAdapter(this, shareList);
		shareLV.setAdapter(adapter);
		shareLV.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> adapterView, View view,
					int position, long arg3) {
				switch (position) {
				case 0: {// 分享到QQ
					shareToQQ();
					break;
				}
				case 1: {// 分享到QQ空间
					shareToQzone();
					break;
				}
				case 2: {// 分享到新浪微博
					shareToSinaWeibo();
					break;
				}
				case 3: {// 分享到微信好友
					showToast("分享中···", true);
					shareToWeChatSession();
					break;
				}
				case 4: {// 分享到微信收藏
					showToast("分享中···", true);
					shareToWeChatFavorite();
					break;
				}
				case 5: {// 分享到微信朋友圈
					showToast("分享中···", true);
					shareToWeChatTimeline();
					break;
				}
				case 6: {// 更多
					share("", null);
					break;
				}
				default:
					break;
				}
			}
		});
	}

	/**
	 * 
	 * @Description: 初始化数据
	 */
	private void initData() {
		// //////////////////////ShareSDK分享配置////////////////////////
		shareParams = new ShareParams();
		// 标题
		shareParams.setTitle("约约约~");
		// 文字
		shareParams.setText("我在“找我”发现美食，快和我约起来吧~");

		// 分享类型 网页
		shareParams.setShareType(Platform.SHARE_WEBPAGE);
		listener = new PlatformActionListener() {

			@Override
			public void onError(Platform arg0, int code, Throwable throwable) {
				LogcatUtils.e("分享失败： " + code + " " + throwable.getMessage());
				theDialog.dismiss();
				showToast("分享失败，请重试~", false);
			}

			@Override
			public void onComplete(Platform platform, int code,
					HashMap<String, Object> map) {
				theDialog.dismiss();
				showToast("分享到" + platform.getName() + "成功~", true);
			}

			@Override
			public void onCancel(Platform arg0, int code) {
				theDialog.dismiss();
				showToast("您已取消分享~", true);
			}
		};
		// //////////////////////友盟分享配置////////////////////////
		// 添加发送QQ好友
		qqHandler = new UMQQSsoHandler(this, CommonConstant.QQ_APP_ID,
				CommonConstant.QQ_APP_SECRET);
		qqHandler.setTitle("约约约~");
		qqHandler.addToSocialSDK();
		// 添加发送QQ空间
		qZoneHandler = new QZoneSsoHandler(this, CommonConstant.QQ_APP_ID,
				CommonConstant.QQ_APP_SECRET);
		qZoneHandler.addToSocialSDK();
		mShareController = UMServiceFactory
				.getUMSocialService("com.umeng.share");
		// 文字
		mShareController.setShareContent("我在“找我”发现美食，快和我约起来吧~");
		// 关闭自身的Toast
		mShareController.getConfig().closeToast();
		snsPostListener = new SnsPostListener() {

			@Override
			public void onStart() {
				showToast("分享中···", true);
			}

			@Override
			public void onComplete(SHARE_MEDIA media, int code,
					SocializeEntity entity) {
				switch (code) {
				case 200: {
					showToast("分享到" + media.name() + "成功~", true);
					break;
				}
				case 40000: {
					showToast("您已取消分享~", true);
					break;
				}
				default: {
					LogcatUtils.e("分享失败： " + code);
					showToast("分享失败 ，请重试~", false);
					break;
				}
				}
				theDialog.dismiss();
			}
		};
		ratingList = new ArrayList<String>();
		ratingList.add("卫生");
		ratingList.add("口味");
		ratingList.add("设施");
		ratingList.add("环境");
		ratingList.add("服务");
		dialog = new CircularLoadingDialog(this);
		// 初始化搜索模块，注册搜索事件监听
		mPoiSearch = PoiSearch.newInstance();
		mPoiSearch.setOnGetPoiSearchResultListener(this);

		mShareUrlSearch = ShareUrlSearch.newInstance();
		OnGetShareUrlResultListener listener = new OnGetShareUrlResultListener() {

			@Override
			public void onGetRouteShareUrlResult(ShareUrlResult result) {

			}

			@Override
			public void onGetLocationShareUrlResult(ShareUrlResult result) {

			}

			@Override
			public void onGetPoiDetailShareUrlResult(ShareUrlResult result) {
				if (result == null
						|| result.error != SearchResult.ERRORNO.NO_ERROR) {
					shareContent = "";
					qqHandler.setTargetUrl(null);
					qZoneHandler.setTargetUrl(null);
					// 网址
					shareParams.setTitleUrl(null);
					// 跳转网页
					shareParams.setUrl(null);
					showShareDialog();
					return;
				}
				if (result.error == SearchResult.ERRORNO.NO_ERROR) {
					shareContent = result.getUrl();
					qqHandler.setTargetUrl(shareContent);
					qZoneHandler.setTargetUrl(shareContent);
					// 网址
					shareParams.setTitleUrl(shareContent);
					// 跳转网页
					shareParams.setUrl(shareContent);
					showShareDialog();
				}
			}
		};
		mShareUrlSearch.setOnGetShareUrlResultListener(listener);

		mRatingBar.setStarHalfDrawable(getResources().getDrawable(
				R.drawable.ic_love_half));// 设置半星
		searchPoiDetail();
	}

	/**
	 * 
	 * @Description: 搜索Poi详情
	 */
	private void searchPoiDetail() {
		if (null == poiInfo || null == poiInfo.uid) {

		} else {
			dialog.show();
			mPoiSearch.searchPoiDetail((new PoiDetailSearchOption())
					.poiUid(poiInfo.uid));
		}
	}

	/**
	 * 
	 * @Description: 搜索Poi详情成功
	 */
	@Override
	public void onGetPoiDetailResult(PoiDetailResult result) {
		dialog.dismiss();
		if (result.error != SearchResult.ERRORNO.NO_ERROR) {
			showToast("抱歉，未找到结果~", false);
		} else {
			LogcatUtils.i(result.getAddress() + "地址\n" + result.getName()
					+ "名称\n" + result.getShopHours() + "营业时间\n"

					+ result.getTag() + "标签\n" + result.getTelephone() + "电话\n"
					+ result.getPrice() + "价格\n" + result.getDetailUrl()
					+ ">getDetailUrl\n" + result.getFavoriteNum() + "喜欢数量\n"
					+ result.getGrouponNum() + "团购数量\n"
					+ result.getCheckinNum() + "签到数量\n"
					+ result.getHygieneRating() + "卫生评价\n"
					+ result.getTasteRating() + "口味评价\n"
					+ result.getFacilityRating() + "设施评价\n"
					+ result.getEnvironmentRating() + "环境评价\n"
					+ result.getServiceRating() + "服务评价\n"
					+ result.getTechnologyRating() + "技术评价\n"
					+ result.getOverallRating() + "综合评价\n");
			this.result = result;
			nameTV.setText(result.getName());
			String tel = result.getTelephone();
			if (null == tel || "".equals(tel)) {
				telTV.setText("暂无");
			} else {
				telTV.setText(tel);
			}
			String address = result.getAddress();
			if (null == address || "".equals(address)) {
				addressTV.setText("暂无");
			} else {
				addressTV.setText(address);
			}
			String tag = result.getTag();
			if (null == tag || "".equals(tag)) {
				tagTV.setText("店铺标签：暂无");
			} else {
				tagTV.setText("店铺标签：" + tag);
			}
			String time = result.getShopHours();
			if (null == time || "".equals(time)) {
				timeTV.setText("营业时间：暂无");
			} else {
				timeTV.setText("营业时间：" + time);
			}
			double price = result.getPrice();
			if (0.0 == price) {
				priceTV.setText("人均消费：暂无");
			} else {
				priceTV.setText("人均消费：" + price + "元");
			}
			mRatingBar.setStar((float) result.getOverallRating());
			Score[] scores = new Score[] {
					new Score((float) result.getHygieneRating()),
					new Score((float) result.getTasteRating()),
					new Score((float) result.getFacilityRating()),
					new Score((float) result.getEnvironmentRating()),
					new Score((float) result.getServiceRating()) };
			setup(mScoreView, mCircularLayout, scores);
		}
	}

	/**
	 * 
	 * @Description: 设置评分数据
	 */
	private void setup(SpiderWebScoreView spiderWebScoreView,
			CircularLayout circularLayout, Score... scores) {
		float[] scoreArray = new float[scores.length];
		for (int w = 0; w < scores.length; w++) {
			scoreArray[w] = scores[w].score;
		}
		spiderWebScoreView.setScores(5.0f, scoreArray);// 设置最大值5.0

		circularLayout.removeAllViews();
		int i = 0;
		for (Score score : scores) {
			TextView scoreTextView = (TextView) LayoutInflater.from(
					getBaseContext()).inflate(R.layout.spider_web_score,
					circularLayout, false);
			scoreTextView.setText(ratingList.get(i++) + " " + score.score);
			if (score.iconId != 0) {
				scoreTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0,
						score.iconId, 0);
			}
			circularLayout.addView(scoreTextView);
		}
	}

	/**
	 * 
	 * @ClassName: 分数
	 */
	public static class Score {
		public float score;
		public int iconId;

		public Score(float score, int iconId) {
			this.score = score;
			this.iconId = iconId;
		}

		public Score(float score) {
			this.score = score;
		}
	}

	@Override
	public void onGetPoiResult(PoiResult result) {

	}

	/**
	 * 
	 * @Description: 按键监听
	 */
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.food_info_back_btn: {// 返回
			finish();
			break;
		}
		case R.id.food_info_share_tv: {// 分享
			// UID：为POI的UID信息，可用POI检索获取
			mShareUrlSearch
					.requestPoiDetailShareUrl(new PoiDetailShareURLOption()
							.poiUid(poiInfo.uid));
			break;
		}
		case R.id.food_info_call_tel_tv: {// 咨询
			if (null == result || null == result.getTelephone()
					|| "".equals(result.getTelephone())) {
				showToast("暂无联系号码~", false);
				return;
			}
			Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:"
					+ result.getTelephone()));
			startActivity(intent);
			break;
		}
		case R.id.food_info_route_tv: {// 路线规划
			if (null == result || null == result.getLocation()) {
				showToast("暂无联系地址~", false);
				return;
			}
			Intent intent = new Intent(this, FoodRouteActivity.class);
			intent.putExtra("foodLocation", result.getLocation());
			startActivity(intent);
			break;
		}

		default:
			break;
		}
	}

	/**
	 * 
	 * @Description: Toast显示信息
	 */
	private void showToast(String message, Boolean isInfo) {
		if (isInfo) {
			ToastUtils.showInfoToast(this, message, R.id.food_info_top_ll);
		} else {
			ToastUtils.showAlertToast(this, message, R.id.food_info_top_ll);
		}

	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		mPoiSearch.destroy();
		mShareUrlSearch.destroy();
	}

	// /////////////////////////分享////////////////////////////////
	/**
	 * 
	 * @Description: 弹出推荐分享框
	 */
	@SuppressLint("NewApi")
	private void showShareDialog() {
		// 获取图片
		bitmap = ScreenUtils.snapShotWithoutStatusBar(this);
		if (null != bitmap) {
			shareImagePath = FileUtils.getImagePath();
			if (null != shareImagePath) {
				FileUtils.saveBitmap(bitmap, shareImagePath);
				if (FileUtils.isFilePathExist(shareImagePath)) {
					shareParams.setImagePath(shareImagePath);
				}
			}
		}
		if (null != shareImagePath) {
			// 图片 QQ,QZone只支持ImagePath,不支持ImageData(Bitmap)
			shareParams.setImagePath(shareImagePath);
		}
		theDialog.show();
		theDialog.setContentView(shareView);
		Window window = theDialog.getWindow();
		window.setGravity(Gravity.BOTTOM);
		window.getDecorView().setPadding(0, 0, 0, 0);
		WindowManager.LayoutParams lp = window.getAttributes();
		lp.width = WindowManager.LayoutParams.MATCH_PARENT;
		lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
		window.setAttributes(lp);
	}

	/**
	 * 
	 * @Description: 分享到QQ好友
	 */
	private void shareToQQ() {
		// ShareSDK图文分享 纯图片分享无法回调
		// shareParams.setText(CommonConstant.SHARE_CONTENT);
		// shareParams.setTitle(CommonConstant.SHARE_TITLE);
		// shareParams.setTitleUrl(CommonConstant.SHARE_TARGET_URL);
		// Platform qqPlatform = ShareSDK.getPlatform(QQ.NAME);
		// qqPlatform.setPlatformActionListener(listener);
		// qqPlatform.share(shareParams);
		// 使用友盟分享 QQ图文分享
		if (AppUtils.isInstallApplication("com.tencent.mobileqq")) {
			if (null != bitmap) {
				mShareController.setShareImage(new UMImage(this, bitmap));
			}
			mShareController.postShare(this, SHARE_MEDIA.QQ, snsPostListener);
		} else {
			showToast("请先安装最新版QQ~", false);
		}
	}

	/**
	 * 
	 * @Description: 分享到空间
	 */
	private void shareToQzone() {
		// 使用ShareSDK分享 图片需要先上传服务器速度慢 空间不支持纯图片
		// shareParams.setTitle(CommonConstant.SHARE_TITLE);
		// shareParams.setTitleUrl(CommonConstant.SHARE_TARGET_URL);
		// shareParams.setText(CommonConstant.SHARE_CONTENT);
		// shareParams.setSite("Lifeassistants");
		// shareParams.setSiteUrl(CommonConstant.SHARE_TARGET_URL);
		// Platform qZonePlatform = ShareSDK.getPlatform(QZone.NAME);
		// // 设置false表示使用SSO授权方式
		// qZonePlatform.SSOSetting(false);
		// qZonePlatform.setPlatformActionListener(listener);
		// qZonePlatform.share(shareParams);
		// 使用友盟分享 QQ空间图文分享
		if (AppUtils.isInstallApplication("com.qzone")
				|| AppUtils.isInstallApplication("com.tencent.mobileqq")) {
			if (null != bitmap) {
				mShareController.setShareImage(new UMImage(this, bitmap));
			}
			mShareController
					.postShare(this, SHARE_MEDIA.QZONE, snsPostListener);
		} else {
			showToast("请先安装最新版QQ空间或QQ~", false);
		}
	}

	/**
	 * 
	 * @Description: 分享到新浪微博
	 */
	private void shareToSinaWeibo() {
		// 新浪微博图文分享
		HashMap<String, Object> hashMap = new HashMap<String, Object>();
		hashMap.put("Id", "1");// 自定义字段，整型，用于您项目中对此平台的识别符
		hashMap.put("SortId", "1");// "此平台在您分享列表中的位置，整型，数值越大越靠后"
		hashMap.put("AppKey", CommonConstant.SINA_APP_ID);// 填写您在新浪微博上注册到的AppKey
		hashMap.put("AppSecret", CommonConstant.SINA_APP_SECRET);// 填写您在新浪微博上注册到的AppSeret
		hashMap.put("RedirectUrl", CommonConstant.SINA_REDIRECT_URL);// 填写您在新浪微博上注册的RedirectUrl
		if (AppUtils.isInstallApplication("com.sina.weibo")) {
			hashMap.put("ShareByAppClient", "true");// 使用客户端进行分享
		} else {
			hashMap.put("ShareByAppClient", "false");// 不使用客户端进行分享
		}
		hashMap.put("Enable", "true");// 布尔值，标记此平台是否有效
		ShareSDK.setPlatformDevInfo(SinaWeibo.NAME, hashMap);
		if (AppUtils.isInstallApplication("com.sina.weibo")) {
			shareParams.setTitle("美食");
			Platform weibo = ShareSDK.getPlatform(SinaWeibo.NAME);
			// 设置false表示使用SSO授权方式
			weibo.SSOSetting(false);
			// 设置分享事件回调
			weibo.setPlatformActionListener(listener);
			weibo.share(shareParams);
		} else {
			// 调用网页授权分享
			OnekeyShare oks = new OnekeyShare();
			oks.setPlatform(SinaWeibo.NAME);
			// 显示编辑页面
			oks.setSilent(false);
			// 显示为Dialog
			oks.setDialogMode();
			oks.setTitle("约约约~");
			oks.setText("我在“找我”发现美食，快和我约起来吧~");
			oks.setTitleUrl(shareContent);
			oks.setUrl(shareContent);
			if (null != shareImagePath) {
				oks.setImagePath(shareImagePath);
			}
			oks.setCallback(listener);
			oks.show(this);
		}
	}

	/**
	 * 
	 * @Description: 分享到微信好友
	 */
	private void shareToWeChatSession() {
		if (AppUtils.isInstallApplication("com.tencent.mm")) {
			Platform wxPlatform = ShareSDK.getPlatform(Wechat.NAME);
			wxPlatform.setPlatformActionListener(listener);
			wxPlatform.share(shareParams);
		} else {
			showToast("请先安装最新版微信~", false);
		}

	}

	/**
	 * 
	 * @Description: 分享到微信朋友圈
	 */
	private void shareToWeChatTimeline() {
		if (AppUtils.isInstallApplication("com.tencent.mm")) {
			Platform wxTimeLinePlatform = ShareSDK
					.getPlatform(WechatMoments.NAME);
			wxTimeLinePlatform.setPlatformActionListener(listener);
			wxTimeLinePlatform.share(shareParams);
		} else {
			showToast("请先安装最新版微信~", false);
		}

	}

	/**
	 * 
	 * @Description: 分享到微信收藏
	 */
	private void shareToWeChatFavorite() {
		if (AppUtils.isInstallApplication("com.tencent.mm")) {
			Platform wxFavoritePlatform = ShareSDK
					.getPlatform(WechatFavorite.NAME);
			wxFavoritePlatform.setPlatformActionListener(listener);
			wxFavoritePlatform.share(shareParams);
		} else {
			showToast("请先安装最新版微信~", false);
		}

	}

	/**
	 * 
	 * @Description: 分享更多
	 */
	private void share(String packages, Uri uri) {
		Intent intent = new Intent(Intent.ACTION_SEND);
		if (uri != null) {
			intent.setType("image/*");
			intent.putExtra(Intent.EXTRA_STREAM, uri);
		} else {
			intent.setType("text/plain");
		}
		intent.putExtra(Intent.EXTRA_SUBJECT, "分享到");
		intent.putExtra(Intent.EXTRA_TEXT, "我在“找我”发现美食，快和我约起来吧~" + shareContent);
		intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		if (!TextUtils.isEmpty(packages))
			intent.setPackage(packages);
		startActivity(Intent.createChooser(intent, "分享到"));
	}
}
